home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
art&graf.ix
/
art-0014
/
extra
/
somb.c
< prev
next >
Wrap
Text File
|
1997-04-16
|
2KB
|
109 lines
extern float sin(),cos(),exp();
int contrl[12], intin[256], ptsin[256], intout[256], ptsout[256];
float x, y, dfy, py, f;
float pi,SIN_THETA,COS_THETA;
int width,xcount,ycount;
int top[1000],bottom[1000];
int handle,height,i,dummy;
int oldx,oldy;
int NUM_LINES;
int pxy[4];
#define TRUE 1
#define FALSE 0
float func()
{
return(cos((x*x+y*y)*5.)*exp(-x*x-y*y));
}
float scalex()
{
float temp;
temp=width/2.;
return((xcount-temp)/width*pi);
}
float scaley()
{
float temp;
temp=NUM_LINES/2.;
return((temp-ycount)/NUM_LINES*pi);
}
unscaley()
{
return((dfy+2.)/4.*height);
}
main()
{
register visible, dy;
/* The following is the setup to use the VDI and AES */
/* Set the system up to do GEM calls*/
appl_init();
/* Get the handle of the desktop */
handle=graf_handle(&width,&height,&dummy,&dummy);
/* Open the workstation. */
for (i=1; i<10; ++i) intin[i] = i;
intin[10] = 2;
v_opnvwk(intin, &handle, intout);
graf_mouse(256,pxy);
width=intout[0];
height=intout[1];
vswr_mode(handle,2);
v_clrwk(handle);
oldx=0;
oldy=0;
NUM_LINES=64;
SIN_THETA=.5;
COS_THETA=0.866;
pi=3.14159;
for (ycount=0; ycount<NUM_LINES; ++ycount) {
y=scaley();
py=y*SIN_THETA;
for (xcount=0; xcount<(width+1); ++xcount) {
x=scalex();
f=func();
dfy=py-f*COS_THETA;
dy=unscale();
if (xcount==0)
visible=FALSE;
else if (ycount==0) {
top[xcount]=dy;
bottom[xcount]=dy;
visible=TRUE; }
else { visible=TRUE;
if (top[xcount]<dy)
top[xcount]=dy;
else if (bottom[xcount]>dy)
bottom[xcount]=dy;
else
visible=FALSE; }
if (visible==TRUE) {
vsl_color(handle,1);
pxy[0]=oldx;
pxy[1]=oldy;
pxy[2]=xcount;
pxy[3]=dy;
v_pline(handle,2,pxy); }
oldx=xcount;
oldy=dy;
}
}
evnt_keybd();
}
ə